package com.ws.mapper;

import com.ws.domain.Tops;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface TopsDao {

    @Select("select * from tops where good_id=#{goodId} and type = #{type}")
    Tops getByGoodIdAndType(@Param("goodId") int goodId, @Param("type") byte type);
    //    分页查询所有今日推荐商品的ID集合的方法
    @Select("select good_id from tops where type = #{type}")
    List<Tops> getGoodIdsByType(@Param("type") byte type);
    //加入今日推荐
    @Insert("insert into tops values(null, #{type}, #{goodId})")
    boolean topSave(@Param("goodId") int goodId, @Param("type") int type);
    //移除今日推荐
    @Delete("delete from tops where good_id=#{goodId} and type = #{type}")
    boolean topDelete(@Param("goodId") int goodId, @Param("type") int type);

}
